home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Timing / EngClock96.lha / EngClock96 / Source / globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-21  |  10.7 KB  |  420 lines

  1. /* Global gear for EngClock */
  2.  
  3.  
  4. /************* Includes ************/
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include <intuition/intuition.h>
  10. #include <dos/dos.h>
  11. #include <dos/dostags.h>
  12. #include <exec/devices.h>
  13. #include <exec/execbase.h>
  14. #include <exec/exec.h>
  15. #include <exec/memory.h>
  16. #include <devices/timer.h>
  17. #include <clib/intuition_protos.h>
  18. #include <libraries/diskfont.h>
  19. #include <clib/diskfont_protos.h>
  20. #include <graphics/scale.h>
  21. #include <clib/graphics_protos.h>
  22. #include <graphics/gfxbase.h>
  23. #include <clib/exec_protos.h>
  24. #include <clib/utility_protos.h>
  25. //#include <proto/timer.h>
  26. #include <clib/timer_protos.h>
  27. #include <pragmas/timer_pragmas.h>
  28. #include <utility/utility.h>
  29. #include <utility/date.h>
  30. #include <workbench/startup.h>
  31. #include <clib/dos_protos.h>
  32. #include <clib/gadtools_protos.h>
  33. #include <datatypes/pictureclass.h>
  34. #include <clib/commodities_protos.h>
  35.  
  36. /************** Defines ***************/
  37.  
  38. #define VERS 1  /* Current version of preferences file */
  39.  
  40. #define PREFS_FILE "s:EngClock.prefs"
  41. #define GUIDECOMMAND "Amigaguide Engclock.guide"
  42. #define ID "EngCPrefs"
  43.  
  44. /* Following for locale */
  45. #define ENGLISH 1
  46. #define FRENCH 2
  47. #define SPANISH 3
  48.  
  49. /******** Global Variables *********/
  50.  
  51. BPTR handle;             /* Used by all file-handing operations */
  52.  
  53. char tmp[50],tmp2[50],line1[200], line2[200];
  54.  
  55. char *engnums[60];
  56.  
  57. int memmins, memhours;
  58.  
  59. BOOL afternoon; /* TRUE = pm, FALSE = am */
  60.  
  61. /* Following for Locale */
  62. int language;
  63. BOOL locale=TRUE;
  64.  
  65. /****** Global Structures *******/
  66.  
  67. struct Screen *pubscreen=NULL; /* Public screen structure */
  68. char screen[200];                  /* Name of above */
  69. char *screenptr = NULL;
  70.  
  71. /* Quick assignment for fonts */
  72.  
  73. struct TextAttr font1=
  74. {
  75.   "topaz.font",
  76.   TOPAZ_EIGHTY,
  77.   (UBYTE)NULL,
  78.   FPF_ROMFONT
  79. };
  80.  
  81. struct Event {
  82.     BOOL used;
  83.     int type;    /* Type of event */
  84.     int hours;    /* Time of event */
  85.     int minutes;
  86.     int timecode;
  87.     char message[256];
  88.     int day;
  89.     int month;
  90.     int year;
  91.     BOOL enabledate;
  92.     int freq;
  93. };
  94.  
  95. struct {
  96. /* Prefs structure used for preferences file format */
  97.  
  98.    char header[10];  /* I.D. Header */
  99.    int vers;         /* Version of preferences file */
  100.    int x;            /* X dimension of window when saved */
  101.    int y;            /* Y dimension of window when saved */
  102.    int width;        /* Width of window when saved */
  103.    int height;       /* Height of window when saved */
  104.    int planguage;    /* Language selected (menu) when saved, low pri */
  105.    int just;         /* Justification of text, 0=Left, 1=Centre */
  106.    short date;       /* Display date?, 0 = No, 1=Yes */
  107.    short wtf;         /* Window to front? */
  108.    int time_col[8];
  109.    int date_col[8];
  110.    short autoadjust;       /* Auto adjust ? */
  111.    char backdrop[256];
  112.    char pub[139];
  113.     char accent[256];        /* Language file for tRanslate */
  114.     char tkey[100];
  115.     char hkey[100];
  116.  
  117.     struct Event events[11];  /* For the alarm! */ 
  118. }prefs;
  119.  
  120. struct {
  121. /* Time structure, set up by gettime() and used globally */
  122.  
  123.    int hours;        /* Number of hours since midnight on system clock */
  124.    int seconds;      /* Number of seconds */
  125.    int minutes;      /* Number of minutes */
  126.    int years;        /* Current year */
  127.    int days;         /* Date in current month */
  128.    int months;       /* Current month */
  129.    int wday;         /* Day in the week 0-6 (starting Sunday) */
  130. }time;
  131.  
  132.  
  133. struct {
  134. /* Font structure, set up by getfont() and used globally */
  135.  
  136.    int x;            /* Width of default graphic font */
  137.    int y;            /* Height of default graphic font */
  138. }font;
  139.  
  140. struct IntuiMessage *message;   /* Set up our message pointer */
  141. extern struct ExecBase *SysBase;
  142. struct timerequest *TimerIO=NULL;
  143. struct Library *TimerBase=NULL;
  144.  
  145. /* Following for screen information routine */
  146. #include "EngClock_Screen.h"
  147.  
  148.    int exit_flag=0;
  149.    struct Window *win_p;  /* Our window pointer */
  150.    struct NewWindow win1;  /* Window structure - assigned later */
  151.  
  152.    /* IntuiText definitions */
  153.  
  154.    /* Main IntuiText for the window text */
  155.  
  156.    struct IntuiText int_text= {
  157.       1,0,JAM1,16,9,NULL,NULL,NULL };
  158.    struct IntuiText date_text = {
  159.       1,0,JAM1,16,19,NULL,NULL,NULL };
  160.  
  161.     struct IntuiText req_text= {
  162.       1,0,JAM1,16,9,NULL,NULL,NULL };
  163.  
  164.    /* IntuiTexts for the about requester */
  165.  
  166.    struct IntuiText about_text[18] = {
  167.       {1,0,JAM1,16,9,NULL,NULL,NULL, },               /* Element 1  */
  168.       {1,0,JAM1,16,17,NULL,NULL,&about_text[0],},     /* Element 2  */
  169.       {1,0,JAM1,16,25,NULL,NULL,&about_text[1],},     /* Element 3  */
  170.       {1,0,JAM1,16,33,NULL,NULL,&about_text[2],},     /* Element 4  */
  171.       {1,0,JAM1,16,41,NULL,NULL,&about_text[3],},     /* Element 5  */
  172.       {1,0,JAM1,16,49,NULL,NULL,&about_text[4],},     /* Element 6  */
  173.       {1,0,JAM1,16,57,NULL,NULL,&about_text[5],},     /* Element 7  */
  174.       {1,0,JAM1,16,65,NULL,NULL,&about_text[6],},     /* Element 8  */
  175.       {1,0,JAM1,16,73,NULL,NULL,&about_text[7],},     /* Element 9  */
  176.       {1,0,JAM1,16,81,NULL,NULL,&about_text[8],},     /* Element 10 */
  177.       {1,0,JAM1,16,89,NULL,NULL,&about_text[9],},     /* Element 11 */
  178.       {1,0,JAM1,16,97,NULL,NULL,&about_text[10],},    /* Element 12 */
  179.       {1,0,JAM1,16,105,NULL,NULL,&about_text[11],},   /* Element 13 */
  180.       {1,0,JAM1,16,113,NULL,NULL,&about_text[12],},   /* Element 14 */
  181.       {1,0,JAM1,16,121,NULL,NULL,&about_text[13],},   /* Element 15 */
  182.       {1,0,JAM1,16,129,NULL,NULL,&about_text[14],},    /* Element 16 */
  183.       {1,0,JAM1,16,137,NULL,NULL,&about_text[15],},    /* Element 17 */
  184.       {1,0,JAM1,16,145,NULL,NULL,&about_text[16],}    /* Element 18 */
  185.    };
  186.  
  187.    struct IntuiText ok_text={
  188.       1,0,JAM1,16,9,NULL,NULL,NULL };
  189.  
  190. /* Menu definitions and structure follow... */
  191.  
  192.    /* First the IntuiText strings for each menu item */
  193.  
  194.    struct IntuiText menu_text1 = {
  195.       2,0,JAM1,0,1,NULL,"Set Prefs...",NULL };
  196.    struct IntuiText menu_text2 = {
  197.       2,0,JAM1,0,1,NULL,"Jump",NULL };
  198.    struct IntuiText menu_text3 = {
  199.       2,0,JAM1,0,1,NULL,"About",NULL };
  200.    struct IntuiText menu_text4 = {
  201.       2,0,JAM1,0,1,NULL,"Quit",NULL };
  202.  
  203.    /* And now the menu bits (in reverse order) */
  204.  
  205.  
  206.    struct MenuItem menu_item4 = {
  207.       NULL,0,30,150,10,ITEMTEXT|
  208.                      ITEMENABLED|
  209.                      COMMSEQ|
  210.                      HIGHCOMP, 0x00000001,(APTR)&menu_text4,NULL,'Q',NULL,
  211.                      MENUNULL,};
  212.    struct MenuItem menu_item3 = {
  213.       &menu_item4,0,20,150,10,ITEMTEXT|
  214.                        ITEMENABLED|
  215.                        HIGHCOMP|
  216.                        COMMSEQ,0x00000001,(APTR) &menu_text3,NULL,'A',NULL,
  217.                        MENUNULL,};
  218.    struct MenuItem menu_item2 = {
  219.       &menu_item3,0,10,150,10,ITEMTEXT|
  220.                        ITEMENABLED|
  221.                        COMMSEQ|
  222.                        HIGHCOMP,0x00000001,(APTR) &menu_text2,NULL,'J',NULL,
  223.                        MENUNULL,};
  224.    struct MenuItem menu_item1 = {
  225.       &menu_item2,0,0,150,10,ITEMTEXT|
  226.                        ITEMENABLED|
  227.                        COMMSEQ|
  228.                        HIGHCOMP,0x00000001,(APTR) &menu_text1,NULL,'S',NULL,
  229.                        MENUNULL,};
  230.    
  231.    /* Finally the menus themselves */
  232.  
  233.    struct Menu menu1 = {
  234.       NULL,0,0,70,0,MENUENABLED,"Project",&menu_item1 };
  235.  
  236.  
  237. /* Global pointers for data used in date */
  238.  
  239. char *months_data[13] = {
  240.    "",
  241.    "January",
  242.    "February",
  243.    "March",
  244.    "April",
  245.    "May",
  246.    "June",
  247.    "July",
  248.    "August",
  249.    "September",
  250.    "October",
  251.    "November",
  252.    "December"
  253. };
  254.  
  255. char *months_data_french[13] = {
  256.    "",
  257.    "Janvier",
  258.    "Février",
  259.    "Mars",
  260.    "Avril",
  261.    "Mai",
  262.    "Juin",
  263.    "Juillet",
  264.    "Août",
  265.    "Septembre",
  266.    "Octobre",
  267.    "Novembre",
  268.    "Décembre"
  269. };
  270.  
  271. char *months_data_spanish[13]={
  272.     "",
  273.     "enero",
  274.     "febrero",
  275.     "marzo",
  276.     "abril",
  277.     "mayo",
  278.     "junio",
  279.     "julio",
  280.     "agosto",
  281.     "septiembre",
  282.     "octubre",
  283.     "noviembre",
  284.     "diciembre"
  285. };
  286.  
  287. char *days_data[7] = {
  288.    "Sunday",
  289.    "Monday",
  290.    "Tuesday",
  291.    "Wednesday",
  292.    "Thursday",
  293.    "Friday",
  294.    "Saturday"
  295. };
  296.  
  297. char *days_data_french[7] = {
  298.    "Dimanche",
  299.    "Lundi",
  300.    "Mardi",
  301.    "Mercredi",
  302.    "Jeudi",
  303.    "Vendredi",
  304.    "Samedi"
  305. };
  306.  
  307. char *days_data_spanish[7] = {
  308.     "Domingo",
  309.     "Lunes",
  310.     "Martes",
  311.     "Miércoles",
  312.     "Jueves",
  313.     "Viernes",
  314.     "Sábado"
  315. };
  316.  
  317. BOOL Wb;  /* Workbench (TRUE) or CLI (FALSE) */
  318. struct WBStartup *Wbs;
  319.  
  320. struct Process *guiproc=NULL;
  321.  
  322. /* Stuff for backdrops */
  323.  
  324. struct Picture
  325. {
  326.    struct BitMapHeader bmhd;  /* format and infos */
  327.    struct BitMap *bmap;       /* bitmap */
  328.    ULONG *palette;            /* color table in LoadRGB32() format */
  329.    LONG palette_size;         /* mem usage */
  330.    LONG palette_entries;      /* number of colors */
  331.    ULONG display_ID;          /* video mode */
  332.    UBYTE *author;             /* author info */
  333.    UBYTE *copyright;          /* copyright info */
  334.    UBYTE *annotation;         /* other info */
  335.    LONG author_size;          /* mem usage */
  336.    LONG copyright_size;       /* mem usage */
  337.    LONG annotation_size;      /* mem usage */
  338. };
  339.  
  340. struct Picture piccy;
  341. BOOL ispicture=FALSE;
  342.  
  343. struct TextAttr about_font = {
  344.     NULL,
  345.     NULL,
  346.     FSF_UNDERLINED,
  347.     NULL
  348. };
  349.  
  350. /* Special access variables */
  351.  
  352. extern struct MsgPort *CxMsgPort;
  353. extern struct MsgPort *menu_msg;
  354. extern struct MsgPort *CxHotKey1;
  355. extern struct MsgPort *CxHotKey2;
  356. extern struct MsgPort *RexxPort;
  357.  
  358. extern CxMsg *CxMessage;
  359.  
  360. /* Lib bases */
  361.  
  362. struct IntuitionBase *IntuitionBase=NULL;
  363. struct GfxBase *GfxBase=NULL;
  364. struct Library *UtilityBase=NULL;
  365. struct Library *GadToolsBase=NULL;
  366. struct Library *DiskfontBase=NULL;
  367. struct Library *CxBase=NULL;
  368. struct Library *WorkbenchBase=NULL;
  369. struct Library *TranslatorBase=NULL;
  370. struct Library *AslBase=NULL;
  371. struct Library *IFFParseBase=NULL;
  372. struct Library *DataTypesBase=NULL;
  373. struct Library *RexxBase=NULL;
  374.  
  375. extern struct Library *DOSBase;
  376.  
  377.  
  378.  
  379. /********* Prototypes ************/
  380.  
  381. short main(void);
  382. void gettime(void);
  383. BOOL  about(void);
  384. short readprefs(void);
  385. void  setupengnums(void);
  386. void  openall(void);
  387. void  closeall(void);
  388. void  getfont(void);
  389. void  clearwindow(void);
  390. short setupmainwindow(void);
  391. short changemenu(void);
  392. short refreshwindow(void);
  393. void setupdate_english(void);
  394. void setupdate_french(void);
  395. void setupdate_spanish(void);
  396.  
  397.  
  398. extern void process_alarm(void);
  399. extern BOOL talk(char *text);
  400. extern int prefsgui(void);
  401. extern BOOL jump(void);
  402. extern short getlocale(void);
  403. extern char *trans(char *text);
  404. extern char *findday(int preset2);
  405. extern char datey[200];
  406. extern BOOL playsam(char *esvxname);
  407. extern void msg(char *msg);
  408. extern BOOL loadpic(char *fname, struct Screen *scr);
  409. extern void pattern(struct Window *win_p, struct Screen *scr,struct Picture pic);
  410. extern void unloadpic(struct Picture pic);
  411. extern BOOL cxinit(void);
  412. extern BOOL wbinit(void);
  413. extern void cxclose(void);
  414. extern void wbclose(void);
  415. extern BOOL wb_ask(char *body, char *opt1, char *opt2);
  416. extern void autoadjust(void);
  417. extern void arexxclose(void);
  418. extern void process_arexx(void);
  419. extern BOOL arexxinit(void);
  420.